package com.ruoyi.play.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.play.domain.WhereToGoModule;
import com.ruoyi.play.service.IWhereToGoModuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 去哪模块Controller
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/play/whereToGoModule")
public class WhereToGoModuleController extends BaseController
{
    @Autowired
    private IWhereToGoModuleService whereToGoModuleService;

    /**
     * 查询去哪模块列表
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:list')")
    @GetMapping("/list")
    public TableDataInfo list(WhereToGoModule whereToGoModule)
    {
        startPage();
        List<WhereToGoModule> list = whereToGoModuleService.selectWhereToGoModuleList(whereToGoModule);
        return getDataTable(list);
    }

    /**
     * 查询去哪模块列表（包含选项）
     */
    @GetMapping("/listWithOptions")
    public AjaxResult listWithOptions(WhereToGoModule whereToGoModule)
    {
        List<WhereToGoModule> list = whereToGoModuleService.selectWhereToGoModuleListWithOptions(whereToGoModule);
        return success(list);
    }

    /**
     * 导出去哪模块列表
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:export')")
    @Log(title = "去哪模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhereToGoModule whereToGoModule)
    {
        List<WhereToGoModule> list = whereToGoModuleService.selectWhereToGoModuleList(whereToGoModule);
        ExcelUtil<WhereToGoModule> util = new ExcelUtil<WhereToGoModule>(WhereToGoModule.class);
        util.exportExcel(response, list, "去哪模块数据");
    }

    /**
     * 获取去哪模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(whereToGoModuleService.selectWhereToGoModuleById(id));
    }

    /**
     * 新增去哪模块
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:add')")
    @Log(title = "去哪模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WhereToGoModule whereToGoModule)
    {
        return toAjax(whereToGoModuleService.insertWhereToGoModule(whereToGoModule));
    }

    /**
     * 修改去哪模块
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:edit')")
    @Log(title = "去哪模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WhereToGoModule whereToGoModule)
    {
        return toAjax(whereToGoModuleService.updateWhereToGoModule(whereToGoModule));
    }

    /**
     * 删除去哪模块
     */
    @PreAuthorize("@ss.hasPermi('play:whereToGoModule:remove')")
    @Log(title = "去哪模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(whereToGoModuleService.deleteWhereToGoModuleByIds(ids));
    }
} 